package teach.aistar.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import teach.aistar.model.entity.CarBrands;
import teach.aistar.model.entity.CarDetail;
import teach.aistar.model.entity.CarStyle;
import teach.aistar.service.ICarBandsService;
import teach.aistar.service.ICarDetailService;
import teach.aistar.service.ICarStyleService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@Controller
@RequestMapping("/carts")
public class CarDetailController {

    @Autowired
    private ICarStyleService iCarStyleService;
    @Autowired
    private ICarBandsService iCarBandsService;
    @Autowired
    private ICarDetailService iCarDetailService;
  @RequestMapping("/detailz")
    public String detail(HttpServletRequest request)
  {
      String pid = request.getParameter("pid");
      Long id = Long.valueOf(pid);
      CarDetail p = iCarDetailService.findById(id);


      Long x= p.getBrId();

      request.setAttribute("detail",p);


      CarBrands carBrands = iCarBandsService.findByID(x);



//      List<CarStyle> carStyles = iCarStyleService.findAll(x);

      request.setAttribute("carBrands",carBrands);
//      request.setAttribute("carStyles",carStyles);

      return "seckilldetail";
  }

}
